const models = require('../models');
class PrizeController{
  constructor(){

  }
  async create(record){
    return await models.prize.create(record);
  }
  async upsert(record){
    return await models.prize.upsert(record);
  }
  async delete(whereObj){
    let result = {};
    if(whereObj.id){
      result.where = whereObj
    }
    return await models.prize.destroy(
      result
    )
  }
  async findAll(whereObj,columnsArr){
    let result = {};
    if(whereObj.id||whereObj.time){
      result.where = whereObj
    }
    if(columnsArr.length){
      result.attributes = columnsArr;
    }
    const records = await models.prize.findAll(
      result
    );
    return records;
  }
  // async update(id, updateObj){
  //   var id = id;
  //   var result = await models.student.update(
  //     updateObj,
  //     {
  //       where: {
  //         id: id
  //       }
  //     }
  //   );
  //   if(result){
  //     return true;
  //   }
  //   return false;
  // }
}

module.exports = new PrizeController();